library(pacman)
pacman::p_load(tidyverse, brms, ggeffects, tidybayes, ROCR, caret, interactions, install = TRUE)
devtools::install_github("hadley/emo")palette = c("#e64626", "#1985a1", "#4c5c68", "#FAC748")
palette_group = c(palette[2], palette[4])
plot_aes = theme_minimal() +
theme(legend.position = "top",
legend.text = element_text(size = 16),
text = element_text(size = 18, family = "Futura Medium"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.text = element_text(color = "black"),
axis.line = element_line(colour = "black"),
axis.ticks.y = element_blank())make_table = function(data) {
data %>%
broom.mixed::tidy(conf.int = TRUE) %>%
filter(effect == "fixed") %>%
mutate(term = gsub("\\(Intercept\\)", "intercept", term),
term = gsub("trial_condregulation", "task condition (mindful attention)", term),
term = gsub("trial_cond_recode", "task condition (mindful attention)", term),
term = gsub("dot_between_std_noc", "signature expression (between)", term),
term = gsub("dot_within_std", "signature expression (within)", term),
term = gsub("dot_sd", "signature expression variability", term),
term = gsub("regulation_expression", "signature expression", term),
term = gsub(":", " x ", term),
`b [95% CI]` = sprintf("%.2f [%.2f, %.2f]", estimate, conf.low, conf.high),) %>%
select(term, `b [95% CI]`) %>%
knitr::kable(digits = 2)
}task_data = read.csv("../data/task/cuereact_all062920.csv", stringsAsFactors = FALSE) %>%
filter(grepl("rating", trial_type)) %>%
select(pID, block_num, trial_num, trial_type, resp, rt, stim) %>%
mutate(trial_cond = ifelse(grepl("friend3|friend4", trial_type), "regulation",
ifelse(grepl("friend1|friend2", trial_type), "up-regulation",
ifelse(grepl("mindful", trial_type), "regulation",
ifelse(grepl("nonalc", trial_type), "non-alcohol reactivity",
ifelse(grepl("rating_alc_react", trial_type), "reactivity", NA))))),
trial_cond = factor(trial_cond, levels = c("non-alcohol reactivity", "reactivity", "regulation", "up-regulation"))) %>%
rename("stimulus" = stim) %>%
filter(!is.na(stimulus))
task_conditions = task_data %>%
select(pID, trial_type) %>%
unique() %>%
filter(grepl("friend|mindful", trial_type) | pID %in% c("sub-MURIP012", "sub-MURIP063", "sub-MURIP078")) %>%
mutate(condition = ifelse(grepl("friend", trial_type), "perspective-taking", "mindful attention")) %>%
select(-trial_type) %>%
unique()
task_data_all = task_data %>%
left_join(., task_conditions) %>%
mutate(condition = ifelse(is.na(condition), "control", condition),
trial_cond = factor(trial_cond, c("non-alcohol reactivity", "reactivity", "regulation", "up-regulation")))
task_mindful = task_data_all %>%
filter(condition == "mindful attention")file_dir = "../data/dots"
file_pattern = "sub.*"
file_list = list.files(file_dir, pattern = file_pattern)
dots_tmp = data.frame()
for (file in file_list) {
tmp = tryCatch(read.table(file.path(file_dir,file), fill = TRUE, header = TRUE, sep = ",") %>%
extract(file, c("pID", "beta"), ".*(sub-MURIC[0-9]{3}|sub-MURIP[0-9]{3})/(beta_[0-9]{4}).nii") %>%
mutate(stimulus = as.character(stimulus)), error = function(e) message(file))
dots_tmp = rbind(dots_tmp, tmp)
rm(tmp)
}
dots = dots_tmp %>%
left_join(., task_conditions) %>%
mutate(condition = ifelse(is.na(condition), "control", condition)) %>%
group_by(pID) %>%
filter(!stimulus == "nan") %>%
mutate(sd3_signal = 3 * sd(mean_signal, na.rm = TRUE),
grand_mean_signal = mean(mean_signal, na.rm = TRUE),
outlier = ifelse(mean_signal > grand_mean_signal + sd3_signal, 1,
ifelse(mean_signal < grand_mean_signal - sd3_signal, 1, 0))) %>%
select(-sd3_signal, -grand_mean_signal) %>%
filter(!outlier == 1)classifier_data = read.csv("../data/mvpa/logistic_stats.csv", stringsAsFactors = FALSE) %>%
rename("pID" = subjectID) %>%
mutate(predicted_factor = ifelse(predicted > .5, "regulate", "react"),
predicted_factor = as.factor(predicted_factor),
actual_factor = ifelse(actual == 1, "regulate", "react"),
actual_factor = as.factor(actual_factor))dot_within_std = within-person centered level-1
signature expression variable; standardized across participantsdot_between_std = grand-mean centered level-2 signature
expression variable; standardized across participantsmerged = task_data_all %>%
full_join(., dots) %>%
filter(!pID == "sub-MURIC303") %>%
filter(trial_cond %in% c("reactivity", "regulation")) %>%
mutate(trial_cond_recode = ifelse(trial_cond == "regulation", .5, -.5),
trial_cond = as.factor(as.character(trial_cond)))
between = merged %>%
select(pID, dot, trial_cond, trial_cond_recode, condition) %>%
group_by(pID, trial_cond, trial_cond_recode, condition) %>%
summarize(dot_between = mean(dot, na.rm = TRUE)) %>%
group_by(condition) %>%
mutate(sd_dot = sd(dot_between, na.rm = TRUE),
dot_between_std_noc = dot_between / sd_dot) %>%
select(-sd_dot)
within = merged %>%
select(pID, block_num, trial_num, dot, condition, trial_cond) %>%
group_by(pID, condition) %>%
mutate(dot_within_c = scale(dot, scale = FALSE, center = TRUE)) %>%
group_by(condition) %>%
mutate(sd_dot = sd(dot_within_c, na.rm = TRUE),
dot_within_std = dot_within_c / sd_dot) %>%
mutate(classifier_accuracy = ifelse(dot > 0 & trial_cond == "regulation", "hit",
ifelse(dot < 0 & trial_cond == "reactivity", "correct rejection",
ifelse(dot > 0 & trial_cond == "reactivity", "false alarm",
ifelse(dot < 0 & trial_cond == "regulation", "miss", NA))))) %>%
select(-sd_dot)
disaggregated = merged %>%
left_join(., between, by = c("pID", "condition", "trial_cond", "trial_cond_recode")) %>%
left_join(., within, by = c("pID", "condition", "trial_num", "block_num", "trial_cond", "dot")) %>%
filter(trial_cond %in% c("reactivity", "regulation"))
disaggregated_mindful = disaggregated %>%
filter(condition == "mindful attention")
disaggregated_control = disaggregated %>%
filter(condition == "control")Here is the weight map from the MVPA analyses:
We expect that we will be able to train a classifier at the run level to distinguish mindful attention from uninstructed reactivity to alcohol cues with greater than chance accuracy decoding.
Results
✅ Average cross-validation decoding accuracy is greater than chance (though there’s lot of room for improvement).
classifier_data %>%
do({
condition = .$condition
pred = prediction(.$predicted, .$actual)
perf = performance(pred, measure = "tpr", x.measure = "fpr")
data.frame(cut = perf@alpha.values[[1]],fpr = perf@x.values[[1]],tpr = perf@y.values[[1]])
}) %>%
ggplot(aes(fpr, tpr)) +
geom_line(color = palette[4], size = 1) +
geom_abline(intercept = 0, slope = 1) +
scale_x_continuous(breaks = seq(0, 1, .2)) +
scale_y_continuous(breaks = seq(0, 1, .2)) +
labs(x = "\nfalse positive rate (1 - specificity)", y = "true positive rate (sensitivity)\n") +
theme(legend.position = c(.8, .3),
legend.spacing.y = unit(-.1, "cm")) +
plot_aescaret::confusionMatrix(classifier_data$predicted_factor, classifier_data$actual_factor)## Confusion Matrix and Statistics
##
## Reference
## Prediction react regulate
## react 59 45
## regulate 52 66
##
## Accuracy : 0.5631
## 95% CI : (0.4951, 0.6293)
## No Information Rate : 0.5
## P-Value [Acc > NIR] : 0.03486
##
## Kappa : 0.1261
##
## Mcnemar's Test P-Value : 0.54239
##
## Sensitivity : 0.5315
## Specificity : 0.5946
## Pos Pred Value : 0.5673
## Neg Pred Value : 0.5593
## Prevalence : 0.5000
## Detection Rate : 0.2658
## Detection Prevalence : 0.4685
## Balanced Accuracy : 0.5631
##
## 'Positive' Class : react
##
Given that the classifier is developed at the run level, we will also confirm that the expression of the mindful attention signature is evident at the trial-level. That is, we expect the signature expression to be higher during mindful attention trials compared to reactivity trials.
Results
✅ Signature expression was higher on average during mindful attention trials than reactivity trials. Applying the signature as a classifier on a trial level, we also observed relatively high accuracy (70%) that is significantly above chance.
data_means = merged %>%
filter(condition == "mindful attention") %>%
mutate(trial_cond = gsub("regulation", "mindful attention", trial_cond),
trial_cond = factor(trial_cond, levels = c("reactivity", "mindful attention")))
data_means %>%
ggplot(aes(trial_cond, dot, color = trial_cond, fill = trial_cond)) +
stat_summary(fun.data = "mean_cl_boot", geom = "bar") +
stat_summary(fun.data = "mean_cl_boot", geom = "errorbar", width = 0, color = "black") +
scale_color_manual(name = "", values = palette) +
scale_fill_manual(name = "", values = palette) +
labs(x = "\ntrial type", y = "signature expression\n") +
plot_aes +
theme(legend.position = "none")make_table(mod_means)| term | b [95% CI] |
|---|---|
| intercept | -7.14 [-7.97, -6.33] |
| trial_condmindfulattention | 13.29 [12.08, 14.54] |
summary(mod_means)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: dot ~ trial_cond + (1 + trial_cond | pID)
## Data: data_means (Number of observations: 2245)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 37)
## Estimate Est.Error l-95% CI u-95% CI
## sd(Intercept) 0.48 0.36 0.02 1.31
## sd(trial_condmindfulattention) 0.59 0.45 0.03 1.67
## cor(Intercept,trial_condmindfulattention) -0.20 0.56 -0.98 0.90
## Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 1.00 874 922
## sd(trial_condmindfulattention) 1.00 1200 1186
## cor(Intercept,trial_condmindfulattention) 1.01 1471 1141
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept -7.14 0.42 -7.97 -6.33 1.00 3232
## trial_condmindfulattention 13.29 0.62 12.08 14.54 1.01 2644
## Tail_ESS
## Intercept 1542
## trial_condmindfulattention 1240
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 14.13 0.21 13.72 14.55 1.00 4109 1340
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
acc_line1 = data.frame(x = c(0, 1), y = c(1, 1))
acc_line2 = data.frame(y = c(0, 1), x = c(0, 0))
merged %>%
filter(condition %in% c("mindful attention")) %>%
filter(!is.na(dot)) %>%
mutate(actual = ifelse(trial_cond == "regulation", 1, 0)) %>%
group_by(condition) %>%
do({
condition = .$condition
pred = prediction(.$dot, .$actual)
perf = performance(pred, measure = "tpr", x.measure = "fpr")
data.frame(cut = perf@alpha.values[[1]],fpr = perf@x.values[[1]],tpr = perf@y.values[[1]])
}) %>%
ggplot(aes(fpr, tpr)) +
geom_line(aes(color = condition), size = 1) +
geom_abline(intercept = 0, slope = 1) +
geom_line(data = acc_line1, aes(x, y)) +
geom_line(data = acc_line2, aes(x, y)) +
scale_color_manual(values = palette_group) +
scale_x_continuous(breaks = seq(0, 1, .2)) +
scale_y_continuous(breaks = seq(0, 1, .2)) +
labs(x = "\nfalse positive rate (1 - specificity)", y = "true positive rate (sensitivity)\n") +
plot_aes +
theme(legend.position = "none",
legend.spacing.y = unit(-.1, "cm"))conf_data = merged %>%
filter(condition == "mindful attention") %>%
filter(!is.na(dot)) %>%
mutate(predicted = ifelse(dot > 0, "regulation",
ifelse(dot < 0, "reactivity", NA)),
predicted = as.factor(predicted),
trial_cond = as.factor(as.character(trial_cond)))
caret::confusionMatrix(conf_data$predicted, conf_data$trial_cond)## Confusion Matrix and Statistics
##
## Reference
## Prediction reactivity regulation
## reactivity 827 333
## regulation 346 739
##
## Accuracy : 0.6976
## 95% CI : (0.6781, 0.7165)
## No Information Rate : 0.5225
## P-Value [Acc > NIR] : <0.0000000000000002
##
## Kappa : 0.3942
##
## Mcnemar's Test P-Value : 0.6451
##
## Sensitivity : 0.7050
## Specificity : 0.6894
## Pos Pred Value : 0.7129
## Neg Pred Value : 0.6811
## Prevalence : 0.5225
## Detection Rate : 0.3684
## Detection Prevalence : 0.5167
## Balanced Accuracy : 0.6972
##
## 'Positive' Class : reactivity
##
mod_behavior %>%
spread_draws(b_Intercept, b_trial_condregulation) %>%
mutate(reactivity = b_Intercept,
mindfulness = b_Intercept + b_trial_condregulation) %>%
gather(`trial type`, value, reactivity, mindfulness) %>%
ggplot(aes(y = "", x = value, fill = `trial type`)) +
stat_halfeye(alpha = .5) +
scale_fill_manual(values = c(palette[2], palette[1])) +
scale_y_discrete(expand = c(.1, .1)) +
coord_cartesian(xlim = c(1.5, 2.5)) +
labs(x = "\npredicted craving rating\n", y = "") +
plot_aesmake_table(mod_behavior)| term | b [95% CI] |
|---|---|
| intercept | 2.00 [1.76, 2.23] |
| task condition (mindful attention) | -0.12 [-0.23, -0.01] |
summary(mod_behavior)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: resp ~ 1 + trial_cond + (1 + trial_cond | pID) + (1 | stimulus)
## Data: disaggregated_mindful (Number of observations: 2214)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 37)
## Estimate Est.Error l-95% CI u-95% CI Rhat
## sd(Intercept) 0.60 0.08 0.47 0.77 1.00
## sd(trial_condregulation) 0.21 0.07 0.06 0.34 1.00
## cor(Intercept,trial_condregulation) -0.09 0.27 -0.53 0.53 1.00
## Bulk_ESS Tail_ESS
## sd(Intercept) 457 713
## sd(trial_condregulation) 385 225
## cor(Intercept,trial_condregulation) 1407 521
##
## ~stimulus (Number of levels: 72)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 0.39 0.04 0.32 0.47 1.01 631 1005
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept 2.00 0.12 1.76 2.23 1.01 289
## trial_condregulation -0.12 0.05 -0.23 -0.01 1.00 1953
## Tail_ESS
## Intercept 641
## trial_condregulation 1717
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 0.85 0.01 0.82 0.87 1.00 3292 1564
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
We expect that people who have greater expression of the mindful attention signature on average (i.e., L2, between-person expression) will also have lower craving ratings on a trial-by-trial basis.
Results
✅ There is a statistically significant interaction between trial type and signature expression, such that people who have higher signature expression on average during mindful attention trials also report lower craving ratings, compared to during reactivity trials.
H3: We expect that trials with greater expression of the mindful attention signature compared to one’s average (i.e., L1, within-person expression) will be associated with lower craving ratings on a trial-by-trial basis.
Results
❌ Directionally, greater signature expression compared to one’s mean is associated with lower craving ratings on mindful attention trials, but this relationship is small and not statistically significant.
merged %>%
filter(condition == "mindful attention") %>%
group_by(pID, trial_cond) %>%
mutate(mean_craving = mean(resp, na.rm = TRUE),
mean_expression = mean(dot, na.rm = TRUE)) %>%
select(pID, trial_cond, mean_expression, mean_craving) %>%
unique() %>%
ggplot(aes(mean_expression, mean_craving, color = trial_cond, fill = trial_cond)) +
geom_jitter(alpha = .5, height = .1) +
geom_smooth(method = "lm") +
scale_color_manual(name = "trial type", values = palette) +
scale_fill_manual(name = "trial type", values = palette) +
labs(x = expression("\nreactivity " * symbol('\254') * " mean signature expression " * symbol('\256') * " mindful attention"),
y = "mean craving rating\n") +
plot_aes +
theme(legend.position = "top")merged %>%
filter(condition == "mindful attention") %>%
group_by(pID, trial_cond) %>%
select(pID, trial_cond, dot, resp) %>%
unique() %>%
ggplot(aes(dot, resp, color = trial_cond, fill = trial_cond)) +
geom_jitter(alpha = .5, height = .1) +
geom_smooth(method = "lm") +
scale_color_manual(name = "trial type", values = palette) +
scale_fill_manual(name = "trial type", values = palette) +
labs(x = expression("\nreactivity " * symbol('\254') * " mean signature expression " * symbol('\256') * " mindful attention"),
y = "mean craving rating\n") +
plot_aes +
theme(legend.position = "top")disaggregated_mindful %>%
ggplot(aes(dot, resp, color = trial_cond, fill = trial_cond)) +
geom_smooth(aes(group = interaction(pID, trial_cond)), method = "lm", se = FALSE, size = .2) +
geom_smooth(method = "lm") +
scale_color_manual(name = "trial type", values = palette) +
scale_fill_manual(name = "trial type", values = palette) +
labs(x = expression("\nreactivity " * symbol('\254') * " signature expression " * symbol('\256') * " mindful attention"),
y = "craving rating\n") +
plot_aes +
theme(legend.position = "top")points_between = disaggregated_mindful %>%
select(pID, resp, trial_cond, dot_between_std_noc) %>%
group_by(pID, trial_cond, dot_between_std_noc) %>%
summarize(resp = mean(resp, na.rm = TRUE)) %>%
mutate(group = ifelse(trial_cond == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")),
type = "between-person") %>%
rename("x" = dot_between_std_noc,
"predicted" = resp)
vals = seq(-2,2,.2)
predicted = ggeffects::ggpredict(mod_h2_int, c("dot_between_std_noc [vals]", "trial_cond"), type = "fe") %>%
data.frame() %>%
mutate(type = "between-person") %>%
mutate(group = ifelse(group == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")))
predicted %>%
ggplot(aes(x, predicted, color = group, fill = group)) +
geom_point(data = points_between, alpha = .4, size = 2) +
geom_line(data = points_between, aes(group = pID), alpha = .4, size = 2, color = "grey") +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(size = 2) +
scale_fill_manual(name = "trial type", values = palette) +
scale_color_manual(name = "trial type", values = palette) +
labs(x = expression("\nreactivity " * symbol('\254') * " signature expression " * symbol('\256') * " mindful attention"),
y = "craving rating\n") +
plot_aes +
theme(legend.position = "top")points_within = disaggregated_mindful %>%
select(pID, resp, trial_cond, dot_within_std) %>%
mutate(group = ifelse(trial_cond == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")),
type = "within-person") %>%
rename("x" = dot_within_std,
"predicted" = resp) #%>%
#filter(x < 2 & x > -2)
vals = seq(-4,4,.2)
predicted = ggeffects::ggpredict(mod_h2_int, c("dot_within_std [vals]", "trial_cond"), type = "fe") %>%
data.frame() %>%
mutate(group = ifelse(group == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")))
predicted %>%
ggplot(aes(x, predicted, color = group, fill = group)) +
stat_smooth(data = points_within, aes(group = interaction(pID, group)), geom = "line", method = "lm", alpha = 0.4, se = FALSE, size = 1) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(size = 2) +
scale_fill_manual(name = "trial type", values = palette) +
scale_color_manual(name = "trial type", values = palette) +
labs(x = "within-person signature expression (SD)",
y = "craving rating\n") +
plot_aes +
theme(legend.position = "top")make_table(mod_h2_int)| term | b [95% CI] |
|---|---|
| intercept | 2.28 [1.90, 2.65] |
| task condition (mindful attention) | -0.21 [-0.69, 0.29] |
| signature expression (between) | 0.28 [-0.02, 0.55] |
| signature expression (within) | -0.02 [-0.07, 0.04] |
| task condition (mindful attention) x signature expression (between) | -0.48 [-0.95, -0.01] |
| task condition (mindful attention) x signature expression (within) | -0.01 [-0.10, 0.08] |
emmeans::emtrends(mod_h2_int, ~ trial_cond, var="dot_between_std_noc") %>%
data.frame() %>%
mutate(`b [95% CI]` = sprintf("%.2f [%.2f, %.2f]", dot_between_std_noc.trend, lower.HPD, upper.HPD),
trial_cond = recode(trial_cond, "regulation" = "mindful attention")) %>%
select(trial_cond, `b [95% CI]`)emmeans::emtrends(mod_h2_int, ~ trial_cond, var="dot_within_std") %>%
data.frame() %>%
mutate(`b [95% CI]` = sprintf("%.2f [%.2f, %.2f]", dot_within_std.trend, lower.HPD, upper.HPD),
trial_cond = recode(trial_cond, "regulation" = "mindful attention")) %>%
select(trial_cond, `b [95% CI]`)summary(mod_h2_int)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: resp ~ 1 + trial_cond * dot_between_std_noc + trial_cond * dot_within_std + (1 + trial_cond * dot_within_std | pID) + (1 | stimulus)
## Data: disaggregated_mindful (Number of observations: 2193)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 37)
## Estimate
## sd(Intercept) 0.60
## sd(trial_condregulation) 0.18
## sd(dot_within_std) 0.04
## sd(trial_condregulation:dot_within_std) 0.10
## cor(Intercept,trial_condregulation) -0.01
## cor(Intercept,dot_within_std) 0.22
## cor(trial_condregulation,dot_within_std) 0.04
## cor(Intercept,trial_condregulation:dot_within_std) -0.39
## cor(trial_condregulation,trial_condregulation:dot_within_std) 0.21
## cor(dot_within_std,trial_condregulation:dot_within_std) -0.16
## Est.Error
## sd(Intercept) 0.08
## sd(trial_condregulation) 0.07
## sd(dot_within_std) 0.03
## sd(trial_condregulation:dot_within_std) 0.05
## cor(Intercept,trial_condregulation) 0.28
## cor(Intercept,dot_within_std) 0.39
## cor(trial_condregulation,dot_within_std) 0.43
## cor(Intercept,trial_condregulation:dot_within_std) 0.30
## cor(trial_condregulation,trial_condregulation:dot_within_std) 0.38
## cor(dot_within_std,trial_condregulation:dot_within_std) 0.43
## l-95% CI u-95% CI
## sd(Intercept) 0.47 0.77
## sd(trial_condregulation) 0.03 0.32
## sd(dot_within_std) 0.00 0.12
## sd(trial_condregulation:dot_within_std) 0.02 0.20
## cor(Intercept,trial_condregulation) -0.53 0.54
## cor(Intercept,dot_within_std) -0.65 0.85
## cor(trial_condregulation,dot_within_std) -0.75 0.78
## cor(Intercept,trial_condregulation:dot_within_std) -0.86 0.30
## cor(trial_condregulation,trial_condregulation:dot_within_std) -0.58 0.85
## cor(dot_within_std,trial_condregulation:dot_within_std) -0.86 0.71
## Rhat Bulk_ESS
## sd(Intercept) 1.00 593
## sd(trial_condregulation) 1.00 551
## sd(dot_within_std) 1.00 1016
## sd(trial_condregulation:dot_within_std) 1.00 963
## cor(Intercept,trial_condregulation) 1.00 2151
## cor(Intercept,dot_within_std) 1.00 3427
## cor(trial_condregulation,dot_within_std) 1.00 2098
## cor(Intercept,trial_condregulation:dot_within_std) 1.00 2289
## cor(trial_condregulation,trial_condregulation:dot_within_std) 1.00 1829
## cor(dot_within_std,trial_condregulation:dot_within_std) 1.00 1348
## Tail_ESS
## sd(Intercept) 917
## sd(trial_condregulation) 321
## sd(dot_within_std) 1262
## sd(trial_condregulation:dot_within_std) 852
## cor(Intercept,trial_condregulation) 1186
## cor(Intercept,dot_within_std) 1660
## cor(trial_condregulation,dot_within_std) 1723
## cor(Intercept,trial_condregulation:dot_within_std) 1269
## cor(trial_condregulation,trial_condregulation:dot_within_std) 1656
## cor(dot_within_std,trial_condregulation:dot_within_std) 1606
##
## ~stimulus (Number of levels: 72)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 0.39 0.04 0.32 0.47 1.00 664 1081
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI
## Intercept 2.28 0.19 1.90 2.65
## trial_condregulation -0.21 0.25 -0.69 0.29
## dot_between_std_noc 0.28 0.15 -0.02 0.55
## dot_within_std -0.02 0.03 -0.07 0.04
## trial_condregulation:dot_between_std_noc -0.48 0.24 -0.95 -0.01
## trial_condregulation:dot_within_std -0.01 0.05 -0.10 0.08
## Rhat Bulk_ESS Tail_ESS
## Intercept 1.01 639 1044
## trial_condregulation 1.00 1440 1237
## dot_between_std_noc 1.01 1179 1225
## dot_within_std 1.00 2984 1509
## trial_condregulation:dot_between_std_noc 1.00 1747 1241
## trial_condregulation:dot_within_std 1.00 2672 1802
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 0.85 0.01 0.82 0.87 1.00 4943 1412
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
To examine divergent validity, we will apply the mindful attention signature to data from a separate group of participants who were instructed to use a different form of cognitive regulation (i.e., not mindful attention) that is not expected to rely on the same brain regions. We expect lower than chance accuracy decoding alcohol regulation versus reactivity trials.
I haven’t done what we laid out in our prereg yet, but here are the same analyses from H1b for the perspective taking group. The classifier is much less accurate in this group (accuracy = 54%) than in the mindful attention group.
data_means = merged %>%
filter(condition == "perspective-taking")
data_means %>%
ggplot(aes(trial_cond, dot, color = trial_cond, fill = trial_cond)) +
stat_summary(fun.data = "mean_cl_boot", geom = "bar") +
stat_summary(fun.data = "mean_cl_boot", geom = "errorbar", width = 0, color = "black") +
scale_color_manual(name = "", values = palette) +
scale_fill_manual(name = "", values = palette) +
labs(x = "\ntrial type", y = "signature expression (dot product)\n") +
plot_aes +
theme(legend.position = "none")make_table(mod_e1)| term | b [95% CI] |
|---|---|
| intercept | -2.25 [-4.01, -0.49] |
| task condition (mindful attention) | 1.91 [0.73, 3.07] |
summary(mod_e1)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: dot ~ trial_cond + (1 | pID)
## Data: data_means (Number of observations: 1620)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 34)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 4.66 0.67 3.50 6.14 1.00 530 660
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept -2.25 0.93 -4.01 -0.49 1.01 598
## trial_condregulation 1.91 0.60 0.73 3.07 1.00 3149
## Tail_ESS
## Intercept 781
## trial_condregulation 1323
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 12.40 0.22 11.97 12.85 1.00 3204 1277
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
acc_line1 = data.frame(x = c(0, 1), y = c(1, 1))
acc_line2 = data.frame(y = c(0, 1), x = c(0, 0))
merged %>%
filter(condition %in% c("perspective-taking", "mindful attention")) %>%
filter(!is.na(dot)) %>%
mutate(actual = ifelse(trial_cond == "regulation", 1, 0)) %>%
group_by(condition) %>%
do({
condition = .$condition
pred = prediction(.$dot, .$actual)
perf = performance(pred, measure = "tpr", x.measure = "fpr")
data.frame(cut = perf@alpha.values[[1]],fpr = perf@x.values[[1]],tpr = perf@y.values[[1]])
}) %>%
ggplot(aes(fpr, tpr)) +
geom_line(aes(color = condition), size = 1) +
geom_abline(intercept = 0, slope = 1) +
geom_line(data = acc_line1, aes(x, y)) +
geom_line(data = acc_line2, aes(x, y)) +
scale_x_continuous(breaks = seq(0, 1, .2)) +
scale_y_continuous(breaks = seq(0, 1, .2)) +
scale_color_manual(name = "", values = palette_group) +
labs(x = "\nfalse positive rate (1 - specificity)", y = "true positive rate (sensitivity)\n") +
plot_aes +
theme(legend.position = c(.75, .15),
legend.spacing.y = unit(-.1, "cm"))conf_data = merged %>%
filter(condition == "perspective-taking") %>%
filter(!is.na(dot)) %>%
mutate(predicted = ifelse(dot > 0, "regulation",
ifelse(dot < 0, "reactivity", NA)),
predicted = as.factor(predicted),
trial_cond = as.factor(as.character(trial_cond)))
caret::confusionMatrix(conf_data$predicted, conf_data$trial_cond)## Confusion Matrix and Statistics
##
## Reference
## Prediction reactivity regulation
## reactivity 469 419
## regulation 341 391
##
## Accuracy : 0.5309
## 95% CI : (0.5062, 0.5554)
## No Information Rate : 0.5
## P-Value [Acc > NIR] : 0.006941
##
## Kappa : 0.0617
##
## Mcnemar's Test P-Value : 0.005221
##
## Sensitivity : 0.5790
## Specificity : 0.4827
## Pos Pred Value : 0.5282
## Neg Pred Value : 0.5342
## Prevalence : 0.5000
## Detection Rate : 0.2895
## Detection Prevalence : 0.5481
## Balanced Accuracy : 0.5309
##
## 'Positive' Class : reactivity
##
We will explore whether expression of the mindful attention signature varies naturally during alcohol cue reactivity among participants not instructed to use mindful attention, and the degree to which expression is related to cravings.
Results
Between-person: ✅ ❌ People with stronger expression of the mindful attention signature on average also report lower craving ratings during exposure to alcohol cues. However, the credible interval includes zero.
Within-person: ✅ Stronger expression of the mindful attention signature compared to one’s average is associated with lower craving ratings during exposure to alcohol cues.
predicted = ggeffects::ggpredict(mod_e2, c("dot_between_std_noc [-2:2]"), type = "fe") %>%
data.frame() %>%
mutate(type = "between-person") %>%
bind_rows(ggeffects::ggpredict(mod_e2, c("dot_within_std [-2:2]"), type = "fe") %>%
data.frame() %>%
mutate(type = "within-person"))
predicted %>%
ggplot(aes(x, predicted, color = type, fill = type)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(size = 1) +
scale_fill_manual(name = "", values = palette[3:4]) +
scale_color_manual(name = "", values = palette[3:4]) +
labs(y = "predicated craving rating\n", x = "\nsignature expression (SD)") +
plot_aes +
theme(legend.position = "top")make_table(mod_e2)| term | b [95% CI] |
|---|---|
| intercept | 1.89 [1.67, 2.12] |
| signature expression (between) | -0.19 [-0.41, 0.04] |
| signature expression (within) | -0.07 [-0.13, -0.02] |
summary(mod_e2)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: resp ~ dot_between_std_noc + dot_within_std + (1 + dot_within_std | pID) + (1 | stimulus)
## Data: disaggregated_control (Number of observations: 1796)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 39)
## Estimate Est.Error l-95% CI u-95% CI Rhat
## sd(Intercept) 0.64 0.08 0.50 0.83 1.00
## sd(dot_within_std) 0.10 0.03 0.03 0.17 1.00
## cor(Intercept,dot_within_std) -0.07 0.31 -0.68 0.52 1.00
## Bulk_ESS Tail_ESS
## sd(Intercept) 471 772
## sd(dot_within_std) 487 582
## cor(Intercept,dot_within_std) 1064 910
##
## ~stimulus (Number of levels: 72)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 0.28 0.03 0.22 0.35 1.00 790 1268
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept 1.89 0.12 1.67 2.12 1.02 354 486
## dot_between_std_noc -0.19 0.11 -0.41 0.04 1.01 410 774
## dot_within_std -0.07 0.03 -0.13 -0.02 1.00 2352 1731
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 0.88 0.02 0.85 0.91 1.00 3358 1632
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
We will also explore the degree to which variability in mindful attention throughout the task is related to alcohol cravings on average. We expect that participants who more consistently express the mindful attention signature also report lower craving over the task.
Results
✅ ❌ Lower variability in expression of the mindful attention signature is related to lower cravings. However, the credible interval includes zero.
e3_data = merged %>%
filter(condition == "mindful attention") %>%
group_by(pID, trial_cond, trial_cond_recode) %>%
mutate(dot_sd = sd(dot, na.rm = TRUE),
mean_expression = mean(dot, na.rm = TRUE))
e3_data %>%
select(pID, trial_cond, dot_sd) %>%
unique() %>%
ggplot(aes(dot_sd, fill = trial_cond)) +
geom_density(color = NA, alpha = .5) +
scale_fill_manual(values = palette) +
plot_aese3_data %>%
ggplot(aes(dot, fill = trial_cond)) +
geom_density(color = NA, alpha = .5) +
facet_wrap(~pID) +
scale_fill_manual(values = palette) +
plot_aespredicted = ggeffects::ggpredict(mod_e3, c("dot_sd", "trial_cond"), type = "fe") %>%
data.frame() %>%
mutate(group = recode(group, "regulation" = "mindful attention"),
group = factor(group, levels = c("reactivity", "mindful attention")))
predicted %>%
ggplot(aes(x, predicted, color = group, fill = group)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(aes(group = group), size = 1) +
scale_fill_manual(name = "trial type", values = palette) +
scale_color_manual(name = "trial type", values = palette) +
labs(y = "predicated craving rating\n", x = "\nsignature expression variability (SD)") +
plot_aes +
theme(legend.position = "top")make_table(mod_e3)| term | b [95% CI] |
|---|---|
| intercept | 1.74 [1.17, 2.29] |
| task condition (mindful attention) | -0.20 [-0.70, 0.34] |
| signature expression variability | 0.02 [-0.02, 0.06] |
| task condition (mindful attention) x signature expression variability | 0.00 [-0.03, 0.04] |
summary(mod_e3)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: resp ~ trial_cond * dot_sd + (1 + trial_cond | pID) + (1 | stimulus)
## Data: e3_data (Number of observations: 2214)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 37)
## Estimate Est.Error l-95% CI u-95% CI Rhat
## sd(Intercept) 0.59 0.08 0.46 0.76 1.00
## sd(trial_condregulation) 0.22 0.06 0.09 0.35 1.01
## cor(Intercept,trial_condregulation) -0.14 0.24 -0.56 0.35 1.01
## Bulk_ESS Tail_ESS
## sd(Intercept) 478 749
## sd(trial_condregulation) 575 466
## cor(Intercept,trial_condregulation) 1094 826
##
## ~stimulus (Number of levels: 72)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 0.39 0.04 0.32 0.48 1.01 479 784
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS
## Intercept 1.74 0.29 1.17 2.29 1.00 585
## trial_condregulation -0.20 0.26 -0.70 0.34 1.00 857
## dot_sd 0.02 0.02 -0.02 0.06 1.00 576
## trial_condregulation:dot_sd 0.00 0.02 -0.03 0.04 1.00 842
## Tail_ESS
## Intercept 1076
## trial_condregulation 1084
## dot_sd 991
## trial_condregulation:dot_sd 1221
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 0.85 0.01 0.82 0.88 1.00 3179 1583
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ratings = read.csv("../data/task/post_scan_ratings.csv", stringsAsFactors = FALSE) %>%
select(DistributionChannel, pID, mindful2) %>%
filter(DistributionChannel == "anonymous" & grepl("muri|MURI", pID)) %>%
extract(pID, c("pID", "number"), "(.*)([0-9]{3})") %>%
mutate(pID = ifelse(pID %in% c("muri", "MURI"), "MURIP", pID),
pID = sprintf("sub-%s%s", toupper(pID), number),
confidence_rating = scale(as.numeric(mindful2), center = TRUE, scale = TRUE)) %>%
select(-number, -mindful2, -DistributionChannel)
merged_ratings = disaggregated_mindful %>%
left_join(., ratings)
merged_ratings %>%
ggplot(aes(confidence_rating)) +
geom_density(color = NA, fill = palette[1]) +
plot_aesvals = seq(-3,3,.2)
ggeffects::ggpredict(mod_ph_craving, terms = c("confidence_rating [vals]", "trial_cond")) %>%
data.frame() %>%
mutate(group = ifelse(group == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention"))) %>%
ggplot(aes(x, predicted, color = group, fill = group)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(size = 2) +
scale_fill_manual(name = "trial type", values = palette) +
scale_color_manual(name = "trial type", values = palette) +
labs(x = "instruction confidence rating (SD)",
y = "craving rating\n") +
plot_aes +
theme(legend.position = "top")make_table(mod_ph_craving)| term | b [95% CI] |
|---|---|
| intercept | 2.06 [1.85, 2.27] |
| confidence_rating | -0.03 [-0.27, 0.18] |
| task condition (mindful attention) | -0.16 [-0.25, -0.06] |
| confidence_rating x task condition (mindful attention) | -0.12 [-0.22, -0.02] |
emmeans::emtrends(mod_ph_craving, ~ trial_cond, var="confidence_rating") %>%
data.frame() %>%
mutate(`b [95% CI]` = sprintf("%.2f [%.2f, %.2f]", confidence_rating.trend, lower.HPD, upper.HPD),
trial_cond = recode(trial_cond, "regulation" = "mindful attention")) %>%
select(trial_cond, `b [95% CI]`)summary(mod_ph_craving)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: resp ~ confidence_rating * trial_cond + (1 + trial_cond | pID)
## Data: merged_ratings (Number of observations: 2054)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 33)
## Estimate Est.Error l-95% CI u-95% CI Rhat
## sd(Intercept) 0.63 0.09 0.48 0.85 1.01
## sd(trial_condregulation) 0.14 0.08 0.01 0.28 1.02
## cor(Intercept,trial_condregulation) -0.24 0.38 -0.87 0.67 1.00
## Bulk_ESS Tail_ESS
## sd(Intercept) 447 585
## sd(trial_condregulation) 319 643
## cor(Intercept,trial_condregulation) 1763 923
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI
## Intercept 2.06 0.11 1.85 2.27
## confidence_rating -0.03 0.11 -0.27 0.18
## trial_condregulation -0.16 0.05 -0.25 -0.06
## confidence_rating:trial_condregulation -0.12 0.05 -0.22 -0.02
## Rhat Bulk_ESS Tail_ESS
## Intercept 1.00 322 641
## confidence_rating 1.02 320 556
## trial_condregulation 1.00 1701 1281
## confidence_rating:trial_condregulation 1.01 1870 1165
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 0.94 0.02 0.91 0.97 1.00 2962 1136
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
ggeffects::ggpredict(mod_ph_expression, terms = c("confidence_rating", "trial_cond")) %>%
data.frame() %>%
mutate(group = ifelse(group == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention"))) %>%
ggplot(aes(x, predicted, color = group, fill = group)) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(size = 2) +
scale_fill_manual(name = "trial type", values = palette) +
scale_color_manual(name = "trial type", values = palette) +
labs(x = "instruction confidence rating (SD)",
y = "signature expression\n") +
plot_aes +
theme(legend.position = "top")make_table(mod_ph_expression)| term | b [95% CI] |
|---|---|
| intercept | -7.28 [-8.22, -6.36] |
| confidence_rating | 0.04 [-0.89, 0.95] |
| task condition (mindful attention) | 13.41 [12.22, 14.64] |
| confidence_rating x task condition (mindful attention) | 0.03 [-1.24, 1.39] |
emmeans::emtrends(mod_ph_expression, ~ trial_cond, var="confidence_rating") %>%
data.frame() %>%
mutate(`b [95% CI]` = sprintf("%.2f [%.2f, %.2f]", confidence_rating.trend, lower.HPD, upper.HPD),
trial_cond = recode(trial_cond, "regulation" = "mindful attention")) %>%
select(trial_cond, `b [95% CI]`)summary(mod_ph_expression)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: dot ~ confidence_rating * trial_cond + (1 + trial_cond | pID)
## Data: merged_ratings (Number of observations: 2086)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 33)
## Estimate Est.Error l-95% CI u-95% CI Rhat
## sd(Intercept) 0.56 0.42 0.02 1.57 1.00
## sd(trial_condregulation) 0.63 0.49 0.02 1.81 1.00
## cor(Intercept,trial_condregulation) -0.19 0.59 -0.97 0.92 1.00
## Bulk_ESS Tail_ESS
## sd(Intercept) 855 913
## sd(trial_condregulation) 805 544
## cor(Intercept,trial_condregulation) 1476 1239
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI
## Intercept -7.28 0.48 -8.22 -6.36
## confidence_rating 0.04 0.48 -0.89 0.95
## trial_condregulation 13.41 0.62 12.22 14.64
## confidence_rating:trial_condregulation 0.03 0.66 -1.24 1.39
## Rhat Bulk_ESS Tail_ESS
## Intercept 1.00 3648 1058
## confidence_rating 1.00 1508 1613
## trial_condregulation 1.01 3006 1406
## confidence_rating:trial_condregulation 1.00 1770 1482
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 14.25 0.22 13.83 14.68 1.00 3415 1473
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
points_between = disaggregated_mindful %>%
select(pID, resp, trial_cond, dot_between_std_noc) %>%
group_by(pID, trial_cond, dot_between_std_noc) %>%
summarize(resp = mean(resp, na.rm = TRUE)) %>%
mutate(group = ifelse(trial_cond == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")),
type = "between-person") %>%
rename("x" = dot_between_std_noc,
"predicted" = resp)
vals = seq(-2,2,.2)
predicted = ggeffects::ggpredict(mod_ph_h2, c("dot_between_std_noc [vals]", "trial_cond"), type = "fe") %>%
data.frame() %>%
mutate(type = "between-person") %>%
mutate(group = ifelse(group == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")))
predicted %>%
ggplot(aes(x, predicted, color = group, fill = group)) +
geom_point(data = points_between, alpha = .4, size = 2) +
geom_line(data = points_between, aes(group = pID), alpha = .4, size = 2, color = "grey") +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(size = 2) +
scale_fill_manual(name = "trial type", values = palette) +
scale_color_manual(name = "trial type", values = palette) +
labs(x = expression("\nreactivity " * symbol('\254') * " signature expression " * symbol('\256') * " mindful attention"),
y = "craving rating\n") +
plot_aes +
theme(legend.position = "top")points_within = disaggregated_mindful %>%
select(pID, resp, trial_cond, dot_within_std) %>%
mutate(group = ifelse(trial_cond == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")),
type = "within-person") %>%
rename("x" = dot_within_std,
"predicted" = resp)
vals = seq(-4,4,.2)
predicted = ggeffects::ggpredict(mod_ph_h2, c("dot_within_std [vals]", "trial_cond"), type = "fe") %>%
data.frame() %>%
mutate(group = ifelse(group == "regulation", "mindful attention", "reactivity"),
group = factor(group, levels = c("reactivity", "mindful attention")))
predicted %>%
ggplot(aes(x, predicted, color = group, fill = group)) +
stat_smooth(data = points_within, aes(group = interaction(pID, group)), geom = "line", method = "lm", alpha = 0.4, se = FALSE, size = 1) +
geom_ribbon(aes(ymin = conf.low, ymax = conf.high), alpha = .2, color = NA) +
geom_line(size = 2) +
scale_fill_manual(name = "trial type", values = palette) +
scale_color_manual(name = "trial type", values = palette) +
labs(x = "within-person signature expression (SD)",
y = "craving rating\n") +
plot_aes +
theme(legend.position = "top")make_table(mod_ph_h2)| term | b [95% CI] |
|---|---|
| intercept | 2.30 [1.90, 2.69] |
| task condition (mindful attention) | -0.20 [-0.68, 0.29] |
| signature expression (between) | 0.27 [-0.02, 0.56] |
| signature expression (within) | -0.01 [-0.07, 0.05] |
| confidence_rating | -0.08 [-0.30, 0.14] |
| task condition (mindful attention) x signature expression (between) | -0.48 [-0.94, -0.00] |
| task condition (mindful attention) x signature expression (within) | -0.02 [-0.11, 0.08] |
emmeans::emtrends(mod_ph_h2, ~ trial_cond, var="dot_between_std_noc") %>%
data.frame() %>%
mutate(`b [95% CI]` = sprintf("%.2f [%.2f, %.2f]", dot_between_std_noc.trend, lower.HPD, upper.HPD),
trial_cond = recode(trial_cond, "regulation" = "mindful attention")) %>%
select(trial_cond, `b [95% CI]`)emmeans::emtrends(mod_ph_h2, ~ trial_cond, var="dot_within_std") %>%
data.frame() %>%
mutate(`b [95% CI]` = sprintf("%.2f [%.2f, %.2f]", dot_within_std.trend, lower.HPD, upper.HPD),
trial_cond = recode(trial_cond, "regulation" = "mindful attention")) %>%
select(trial_cond, `b [95% CI]`)summary(mod_ph_h2)## Family: gaussian
## Links: mu = identity; sigma = identity
## Formula: resp ~ 1 + trial_cond * dot_between_std_noc + trial_cond * dot_within_std + confidence_rating + (1 + trial_cond * dot_within_std | pID) + (1 | stimulus)
## Data: merged_ratings (Number of observations: 2034)
## Draws: 4 chains, each with iter = 1000; warmup = 500; thin = 1;
## total post-warmup draws = 2000
##
## Group-Level Effects:
## ~pID (Number of levels: 33)
## Estimate
## sd(Intercept) 0.63
## sd(trial_condregulation) 0.18
## sd(dot_within_std) 0.05
## sd(trial_condregulation:dot_within_std) 0.11
## cor(Intercept,trial_condregulation) -0.11
## cor(Intercept,dot_within_std) 0.18
## cor(trial_condregulation,dot_within_std) 0.03
## cor(Intercept,trial_condregulation:dot_within_std) -0.34
## cor(trial_condregulation,trial_condregulation:dot_within_std) 0.23
## cor(dot_within_std,trial_condregulation:dot_within_std) -0.15
## Est.Error
## sd(Intercept) 0.09
## sd(trial_condregulation) 0.07
## sd(dot_within_std) 0.03
## sd(trial_condregulation:dot_within_std) 0.05
## cor(Intercept,trial_condregulation) 0.29
## cor(Intercept,dot_within_std) 0.40
## cor(trial_condregulation,dot_within_std) 0.42
## cor(Intercept,trial_condregulation:dot_within_std) 0.31
## cor(trial_condregulation,trial_condregulation:dot_within_std) 0.38
## cor(dot_within_std,trial_condregulation:dot_within_std) 0.45
## l-95% CI u-95% CI
## sd(Intercept) 0.49 0.85
## sd(trial_condregulation) 0.04 0.32
## sd(dot_within_std) 0.00 0.12
## sd(trial_condregulation:dot_within_std) 0.01 0.21
## cor(Intercept,trial_condregulation) -0.62 0.48
## cor(Intercept,dot_within_std) -0.65 0.84
## cor(trial_condregulation,dot_within_std) -0.79 0.79
## cor(Intercept,trial_condregulation:dot_within_std) -0.85 0.34
## cor(trial_condregulation,trial_condregulation:dot_within_std) -0.57 0.86
## cor(dot_within_std,trial_condregulation:dot_within_std) -0.86 0.75
## Rhat Bulk_ESS
## sd(Intercept) 1.01 482
## sd(trial_condregulation) 1.00 561
## sd(dot_within_std) 1.00 1086
## sd(trial_condregulation:dot_within_std) 1.01 720
## cor(Intercept,trial_condregulation) 1.00 1532
## cor(Intercept,dot_within_std) 1.00 3109
## cor(trial_condregulation,dot_within_std) 1.00 2270
## cor(Intercept,trial_condregulation:dot_within_std) 1.00 2070
## cor(trial_condregulation,trial_condregulation:dot_within_std) 1.00 1435
## cor(dot_within_std,trial_condregulation:dot_within_std) 1.00 1134
## Tail_ESS
## sd(Intercept) 1070
## sd(trial_condregulation) 420
## sd(dot_within_std) 1468
## sd(trial_condregulation:dot_within_std) 714
## cor(Intercept,trial_condregulation) 1540
## cor(Intercept,dot_within_std) 1496
## cor(trial_condregulation,dot_within_std) 1726
## cor(Intercept,trial_condregulation:dot_within_std) 1182
## cor(trial_condregulation,trial_condregulation:dot_within_std) 1379
## cor(dot_within_std,trial_condregulation:dot_within_std) 1556
##
## ~stimulus (Number of levels: 72)
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept) 0.40 0.04 0.33 0.49 1.00 762 949
##
## Population-Level Effects:
## Estimate Est.Error l-95% CI u-95% CI
## Intercept 2.30 0.20 1.90 2.69
## trial_condregulation -0.20 0.24 -0.68 0.29
## dot_between_std_noc 0.27 0.15 -0.02 0.56
## dot_within_std -0.01 0.03 -0.07 0.05
## confidence_rating -0.08 0.12 -0.30 0.14
## trial_condregulation:dot_between_std_noc -0.48 0.23 -0.94 -0.00
## trial_condregulation:dot_within_std -0.02 0.05 -0.11 0.08
## Rhat Bulk_ESS Tail_ESS
## Intercept 1.01 777 1034
## trial_condregulation 1.00 1476 1419
## dot_between_std_noc 1.00 1360 1217
## dot_within_std 1.00 2134 1538
## confidence_rating 1.01 488 628
## trial_condregulation:dot_between_std_noc 1.00 2276 1680
## trial_condregulation:dot_within_std 1.00 2176 1181
##
## Family Specific Parameters:
## Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sigma 0.85 0.01 0.82 0.87 1.00 3617 1742
##
## Draws were sampled using sampling(NUTS). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).
Compare preregistered model with the modeling controlling for confidence ratings
posterior = posterior_samples(mod_h2_int) %>%
transmute(`mindful attention`= b_dot_between_std_noc + `b_trial_condregulation:dot_between_std_noc`,
reactivity = b_dot_between_std_noc) %>%
gather(`trial type`, value) %>%
mutate(model = "original model") %>%
bind_rows(posterior_samples(mod_ph_h2) %>%
transmute(`mindful attention`= b_dot_between_std_noc + `b_trial_condregulation:dot_between_std_noc`,
reactivity = b_dot_between_std_noc) %>%
gather(`trial type`, value) %>%
mutate(model = "controlling for confidence")) %>%
mutate(model = factor(model, levels = c("original model", "controlling for confidence")))
posterior %>%
ggplot(aes(y = "", x = value, fill = `trial type`)) +
stat_halfeye(alpha = .5) +
scale_fill_manual(values = c(palette[2], palette[1])) +
facet_grid(~model) +
scale_y_discrete(expand = c(.1, .1)) +
labs(x = "\nregression coefficient\n", y = "") +
plot_aesposterior %>%
ggplot(aes(y = "", x = value, fill = model)) +
stat_halfeye(alpha = .5) +
scale_fill_manual(values = palette_group) +
facet_grid(~`trial type`) +
scale_y_discrete(expand = c(.1, .1)) +
labs(x = "\nregression coefficient\n", y = "") +
plot_aes